import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    arr:[],
    zhuangtai:'all'
  },
  getters:{
    zhuangtai:function(state){
      return state.zhuangtai
    },
    guolvqi:function(state){
      if(state.zhuangtai == 'all'){
        return state.arr
      }else if(state.zhuangtai == 'ing'){
        return state.arr.filter((v)=>{
          return !v.duicou
        })
      }else if(state.zhuangtai == 'ok'){
        return state.arr.filter((v)=>{
          return v.duicou
        })
      }
    }
  },
  mutations: {
    add: function (state, { payload }) {
      state.arr.push(payload);
    },
    gaizhuangtai: function (state, { payload }) {
      state.zhuangtai = payload.a;
    },
    shangchu: function (state, { payload }) {
      state.arr.splice(payload.i, 1);
    },
  },
  actions: {
  },
  modules: {
  }
})
